package repository;

import java.rmi.Naming;
import java.util.Scanner;


public class RunRepository {
	
	public RunRepository(String fName){
		try{
			RepositoryImpl repo = new RepositoryImpl();
//			Registry reg = LocateRegistry.createRegistry(1100);
//			reg.rebind("repository", repo);
//			for (String x: reg.list())
//				System.out.println(x);
			Naming.rebind("repository", repo);
			
			repo.readFile("../src/"+fName);		
//			System.out.println(repo.getMusic(1));
//			System.out.println(repo.getSongLength());
			System.out.println("Repository is running");
		}
		catch(Exception e){
			System.out.println("Error initialising repository: " + e.getMessage());
		}
		
	}
	
	public static void main(String[] args){
		System.out.println("Please enter music filename:");
		Scanner scanner = new Scanner(System.in);
		new RunRepository(scanner.next());
	}

}
